package Bebetter.Day02;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author:galaxy_yan
 * @Date: 2022/11/22
 * @Time: 16:20
 * @Description 排序子序列
 */
public class B1 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
//        1、数据接收
        int[] arr=new int[n];
        for (int i = 0; i < arr.length; i++) {
            arr[i]= sc.nextInt();
        }
        int[] num=new int[n-1];
        for (int i = 0; i < arr.length-1; i++) {
            num[i]=arr[i+1]-arr[i];
        }
        int count=0;
        for (int i = 1; i < num.length-1; i++) {
            if(num[i]==0){
                continue;
            }
            if(num[i]>0 && num[i-1]<0){
                count++;
            }
            if(num[i] <0 && num[i-1] >0){
                count++;
            }
        }
        System.out.println(count);
    }
}
